package harima.collision.bodies;

import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;


public abstract class Direction {

	private short movementX;

	private short movementY;

	protected Direction(short movx, short movy) {
		movementX = movx;
		movementY = movy;
	}

	public abstract Line2D.Float getSide(Rectangle2D.Float body);
	public abstract Direction getOpositeDirection();
	
	public static final Direction Left = new Left();
	public static final Direction Right = new Right();
	public static final Direction Up = new Up();
	public static final Direction Down = new Down();
	
	public short getMovementX(){
		return movementX;
	}
	
	public short getMovementY()
	{
		return movementY;
	}

	
	
}

class Left extends Direction {

	protected Left() {
		super((short) -1, (short) 0);
		// TODO Auto-generated constructor stub
	}

	
	public Line2D.Float getSide(Rectangle2D.Float body) {
		// TODO Auto-generated method stub
		Line2D.Float side = new Line2D.Float();
		side.x1 = body.x;
		side.y1 = body.y;
		side.x2 = body.x;
		side.y2 = body.y + body.height;
		return side;
	}
	
	public Direction getOpositeDirection()
	{
		return Direction.Right;
	}
	

}

class Right extends Direction{
	
	public Right()
	{
		super((short)1,(short)0);
	}
	
	public Line2D.Float getSide(Rectangle2D.Float body)
	{
		Line2D.Float side = new Line2D.Float();
		
		side.x1 = body.x+body.width;
		side.y1 = body.y;
		side.x2 = body.x+body.width;
		side.y2 = body.y+body.height;
		
		return side;
	}
	
	public Direction getOpositeDirection()
	{
		return Direction.Left;
	}
}

class Up extends Direction
{
	public Up()
	{
		super((short)0, (short)-1);
	}
	
	public Line2D.Float getSide(Rectangle2D.Float body)
	{
		Line2D.Float side = new Line2D.Float();
		
		side.x1 = body.x;
		side.y1 = body.y;
		side.x2 = body.x+body.width;
		side.y2 = body.y;
		
		return side;
	}
	
	public Direction getOpositeDirection()
	{
		return Direction.Down;
	}
}

class Down extends Direction
{
	public Down()
	{
		super((short)0,(short)1);
	}
	
	public Line2D.Float getSide(Rectangle2D.Float body)
	{
		Line2D.Float side = new Line2D.Float();
		side.x1 = body.x;
		side.y1 = body.y+body.height;
		side.x2 = body.x+body.width;
		side.y2 = body.y+body.height;
		return side;
	}
	
	public Direction getOpositeDirection()
	{
		return Direction.Up;
	}
}